package com.simple.controller;

import com.simple.common.PageResult;
import com.simple.common.Result;
import com.simple.dto.BillDTO;
import com.simple.dto.FundDTO;
import com.simple.service.FundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName FundController
 * @Author SimpleTree
 **/
@RequestMapping("/fund")
@RestController
public class FundController {

    @Autowired
    private FundService fundService;

    @GetMapping
    public Result getFunds(FundDTO fundDTO) {
        return Result.of(fundService.getFunds(fundDTO));
    }

    @GetMapping("/getFundById/{id}")
    public Result getFundById(@PathVariable Integer id) {
        return Result.of(fundService.getFundById(id));
    }

    @PostMapping
    public Result saveFund(@RequestBody FundDTO fundDTO) {
        fundService.saveFund(fundDTO);
        return Result.of();
    }

    @PutMapping
    public Result updateFund(@RequestBody FundDTO fundDTO) {
        fundService.updateFund(fundDTO);
        return Result.of();
    }

    @DeleteMapping
    public Result deleteByIds(@RequestParam List<Integer> ids) {
        fundService.deleteByIds(ids);
        return Result.of();
    }

    @PostMapping("/updateDel")
    public Result updateDel(@RequestBody FundDTO fundDTO) {
        fundService.updateDel(fundDTO);
        return Result.of();
    }
}
